<?
class BaseAction extends Action {
  private $_ignoreAction = array('login');//不检查登陆状态的Action
  function _initialize() {
    $this->assign('waitSecond', 1);
    if (!in_array(ACTION_NAME, $this->_ignoreAction)) {
      $this->_checkLogin();
    }
  }

  private function _checkLogin() {
    if ($_SESSION['user_name'] != "ehs" && $_SESSION['password'] != "ehscn") {
      $this->assign("jumpUrl", __URL__.'/login/');
      $this->error("你还没有登陆，请登录");
    }
  }

  public function login() {
    if ($_POST) {
      if ($_POST['user_name'] == 'ehs' && $_POST['password'] == 'ehscn') {
        $_SESSION['admin_name'] = "ehs";
        $_SESSION['password'] = "ehscn";
		$_SESSION['isAdmin']="1";
		$_SESSION['admin_id']="3";
        $this->assign(jumpUrl, __URL__.'/index');
        $this->success("登陆成功，页面跳转中");
      }else {
        $this->assign("jumpUrl", __URL__.'/login');
        $this->error('登陆失败，请重新登陆');
      }
    }else $this->display('Public:login');
  }
}
?>